﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using eSYSU.Common;


namespace eSYSU.Model
{
    /// <summary>
    /// 新闻模型类
    /// </summary>
    public class News
    {
        public News()
        {
            //
            //TODO: 在此处添加构造函数逻辑
            //
        }
        public int id { set; get; }              //新闻编号
        public int collegeid { set; get; }       //新闻分类编号
        public string title { set; get; }        //新闻标题
        public string author { set; get; }       //作者
        public DateTime posttime { set; get; }   //新闻发布时间
        public DateTime embodytime { set; get; } //新闻收录时间
        public string origin { set; get; }       //新闻来源
        public string brief { set; get; }        //新闻简介
        public string content { set; get; }      //新闻正文
        public string keyword { set; get; }      //新闻标签/关键字
        public string originalurl { set; get; }  //原文链接地址


        //新闻编号
        //public int id
        //{
        //    set { _id = value; }
        //    get { return _id; }
        //}

        /// <summary>
        /// 将News对象格式化为XML字符串
        /// </summary>
        /// <param name="iImageSize">图片大小（0~4）</param>
        /// <returns>XML字符串</returns>
        public string ToXmlString(int iImagesSize)
        {
            System.Text.StringBuilder news = new System.Text.StringBuilder();

            //news.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?> ");
            news.Append("<News>");
            news.Append("<NewsID>" + id.ToString() + "</NewsID>");
            news.Append("<CollegeID>" + collegeid.ToString() + "</CollegeID>");
            news.Append("<Title>" + title + "</Title>");
            news.Append("<Author>" + author + "</Author>");
            news.Append("<Posttime>" + posttime.ToLocalTime() + "</Posttime>");
            news.Append("<Embodytime>" + embodytime.ToLocalTime() + "</Embodytime>");
            news.Append("<Origin>" + origin + "</Origin>");
            news.Append("<Brief>" + brief + "</Brief>");
            news.Append("<Content><![CDATA[" + StringHelper.ChangeImageUrlForMobile(content, iImagesSize) + "]]></Content>");
            news.Append("<Keyword>" + keyword + "</Keyword>");
            news.Append("<Originalurl>" + originalurl + "</Originalurl>");
            news.Append("</News>");

            return news.ToString();
        }
    }
}